<template>
  <div class="total-box">
    <!-- 搜索 -->
    <div class="section1">
      <div class="section1-1">
        <i class="el-icon-search" @click="sousuo"></i>
        <input
          type="text"
          placeholder="请输入内容"
          v-model="filterText"
          class="input1"
          @input="textNone1($event)"
          @keyup.enter="textNone($event)"
        />
      </div>
      <div class="section1-1 spe" @click="setProporation()">
        设置分成比例
      </div>
    </div>
    <el-dialog
      :visible.sync="dialogVisible"
      width="35%"
    >
      请输入分成比例：<input type="text" placeholder="" class="updateone" v-model="oneBind"/>
      <span slot="footer" class="dialog-footer">
        <!-- <el-button @click="dialogVisible = false">取 消</el-button> -->
        <el-button type="primary" @click="updateProporation1()"
          >确 定</el-button
        >
      </span>
    </el-dialog>

    <!-- 表格数据 -->
    <div>
      <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="user_id" label="用户编号"></el-table-column>
        <el-table-column prop="user_name" label="用户名称"></el-table-column>
        <el-table-column prop="proxy_id" label="代理名称">
          <template slot-scope="scope">
            <span v-if="scope.row.proxy_id == 1" v-text="'一级代理'"></span>
            <span v-if="scope.row.proxy_id == 2" v-text="'二级代理'"></span>
            <span v-if="scope.row.proxy_id == 3" v-text="'三级代理'"></span>
          </template>
        </el-table-column>
        <el-table-column
          prop="proxy.proxy_split_ratio"
          label="分成比例"
        ></el-table-column>
        <el-table-column
          prop="proxy.proxy_remark"
          label="代理描述"
        ></el-table-column>
        <el-table-column prop="proxy_id" label="代理级别"></el-table-column>
        <!-- <el-table-column label="操作">
          <template slot-scope="scope">
            <el-dropdown>
              <span class="el-dropdown-link">
                <i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item @click.native="modify(scope.row, 0)"
                  >编辑</el-dropdown-item
                >
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column> -->
      </el-table>
    </div>
    <!-- 分页 -->
    <div class="paging">
      <el-pagination
        @current-change="handleCurrentChange"
        :current-page.sync="currentPage"
        :page-size="pageNum"
        layout="prev, pager, next, jumper"
        :total="drugList"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
import http from '../api';
export default {
  data() {
    return {
      filterText: '',
      tableData: [],
      currentPage: 1,
      pageNum: 6,
      drugList: 0,
      dialogVisible: false,
      oneBind:''
    };
  },
  computed: {},
  mounted() {
    this.getData();
  },
  methods: {
    updateProporation1(){
       http.upPropogation({
         proxy_id:'1',
         proxy_split_ratio:this.oneBind
       }).then(r=>{
         console.log(r);
          this.tableData=r.data.data;
          this.dialogVisible=false;
       })
    },
    setProporation() {
      this.dialogVisible=true;
    },
    textNone(e) {
      console.log(e);
      this.getData();
    },
    textNone1(e) {
      if (e.target.value == '') {
        this.currentPage = 1;
        this.getData();
      }
    },
    modify(row, index) {
      // this.$refs.modifyinfo.open(row);
      //返回当前对象
      console.log(row, index);
    },
    sousuo() {
      console.log(1111);
      this.getData();
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      console.log(val);
      this.getData();
    },
    //获取数据
    getData() {
      http
        .firstLevelData({
          params: {
            pages: this.currentPage,
            pageSize: this.pageNum,
            proxy_id: 1,
            content: this.filterText
          }
        })
        .then(r => {
          console.log(r);
          this.drugList = r.data.counts;
          this.tableData = r.data.data;
        });
    }
  }
};
</script>
<style scoped>
.updateone{
  width: 250px;
  height: 35px;
  border: 1px solid gainsboro;
  border-radius: 5px;
  outline: none;
}
.section1 {
  margin-bottom: 40px;
  display: flex;
}
.section1-1 {
  width: 190px;
  height: 40px;
  border: 1px solid gainsboro;
  display: flex;
  justify-content: center;
  background-color: white;
  align-items: center;
}
.spe {
  width: 150px;
  height: 40px;
  margin-left: 30px;
  border: none;
  background-color: #494b4c;
  color: white;
}
.input1 {
  width: 150px;
  height: 30px;
  border: none;
  margin-left: 10px;
  outline: none;
}
.section1-1 .input2 {
  width: 180px;
  height: 35px;
  outline: none;
  border: 1px solid gainsboro;
}
.paging {
  margin-top: 30px;
  margin-left: 30%;
  position: absolute;
  left: 190px;
  bottom: 60px;
}

.el-pagination >>> .el-pagination__jump {
  font-size: 17px;
}
.el-pagination >>> .el-icon {
  font-size: 17px;
}
.el-pagination >>> .number {
  font-size: 17px;
  width: 60px;
}
.total-box {
  background-color: white;
  padding-top: 30px;
  margin-top: 10px;
  height: 600px;
}
</style>
